// 为了提示用户这不是系统菜单。
@keyframes contextMenuInSpecial {
  from {
    transform: scale3d(1, 1, 1);
  }

  50% {
    transform: scale3d(1.05, 1.05, 1.05);
  }

  to {
    transform: scale3d(1, 1, 1);
  }
}

@keyframes contextMenuIn {
  from {
    opacity: 0;
  }
}

@keyframes contextMenuOut {
  to {
    opacity: 0;
  }
}

.#{$ns}ContextMenu {
  z-index: $zindex-contextmenu;
  position: fixed;
  left: 0;
  top: 0;
  // pointer-events: none;

  &-menu {
    position: absolute;
    z-index: $zindex-contextmenu;

    &.in,
    &.out {
      // opacity: 1;
      // transform: translateY(0) scale(1);
      animation-duration: var(--animation-duration);
      animation-fill-mode: both;
    }

    &.in {
      animation-name: contextMenuInSpecial;
      animation-duration: var(--animation-duration);
    }

    &.out {
      animation-name: contextMenuOut;
    }

    display: block;
    position: absolute;

    margin: 0;
    padding: var(--menu-padding);

    background: var(--menu-background);
    box-shadow: var(--menu-box-shadow);
    border-radius: var(--Context-menu-border-radius);

    color: var(--menu-font-color);
    font-family: var(--menu-font-family);
    font-size: 12px;
    line-height: 20px;
  }

  &-divider {
    border: none;
    height: 1px;
    background: var(--menu-border-color);
    margin: 4px 1px;
    padding: 0;
  }

  &-list {
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: var(--menu-min-width);
  }

  &-item {
    position: relative;

    > a {
      white-space: nowrap;
      display: block;
      padding: var(--menu-font-padding);
      font-size: var(--menu-font-size);
      color: var(--menu-font-color);
      border-top: none;
      border-bottom: none;
      display: flex;
      align-items: center;
      justify-content: space-between;
      > i {
        font-size: 12px;
      }
    }

    &:not(.is-disabled):hover > a {
      text-decoration: none;
      background: var(--Context-menu-hover-bg-color);
      border-radius: var(--Context-menu-border-radius);
      color: var(--Context-menu-hover-color);
      cursor: pointer;
      border-top: none;
      border-bottom: none;
    }

    &.is-disabled > a {
      color: var(--menu-disabled-color);
      pointer-events: none;
    }

    &.is-active > a {
      color: var(--Context-menu-active-color);
    }

    &.has-child {
      &::after {
        position: absolute;
        content: '';
        width: 12px;
        position: absolute;
        right: -12px;
        top: 0;
        bottom: 0;
        z-index: 1;
      }
    }

    &.is-danger {
      > a {
        color: var(--danger-color);
      }
    }
  }

  &-itemIcon {
    margin-right: 5px;
  }

  &-subList {
    display: none;
    list-style: none;
    transition: display ease-out 0.25s;
  }

  &-item:hover > &-subList {
    display: block;
    min-width: var(--menu-min-width);
    animation-duration: var(--animation-duration);
    animation-fill-mode: both;
    animation-name: contextMenuIn;
    position: absolute;
    left: calc(100% + 8px);
    top: -3px;
    margin: 0;
    padding: var(--menu-padding);
    background: var(--menu-background);
    box-shadow: var(--menu-box-shadow);
    border-radius: var(--Context-menu-border-radius);

    color: var(--Context-menu-hover-color);
    font-family: var(--menu-font-family);
    font-size: 12px;
    line-height: 20px;
    max-height: 500px;
    overflow-y: auto;

    &:hover {
      display: block;
    }
  }

  &--left &-item:hover > &-subList {
    left: auto;
    right: 100%;
  }

  &-cursor {
    position: absolute;
    width: 1px;
    height: 1px;
    z-index: -1;
  }

  &-overlay {
    position: fixed !important;
    z-index: $zindex-contextmenu - 1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
  }
}
